<template>
	<view :style="viewStyle">
		<web-view :style="viewStyle" :src="webUrl" @message="handleMessage"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				webUrl: '',
				viewStyle: {
					height: '100%',
					width: '100%'
				}
			};
		},
		onLoad(options) {
			// 获取webUrl
			this.webUrl = options.url;
			// #ifdef H5
			window.addEventListener("message", (event) => {
				// 全量打印
				// 只看关键消息
				console.log(event.data)
				let event_data = event.data.data.arg
				console.log(event_data)
				if(event.type=='message'){
					// uni.redirectTo({
					// 	url: '/pages/index/reserve/my-trip'
					// });
					uni.redirectTo({
						url:"/pages/user/my-order/orders"
					})
				}
			}, false)
			// #endif
		},
		methods: {
			handleMessage(e) {
				if (e.type == 'message') {
					// 跳转到App端的订单列表页
					// uni.redirectTo({
					// 	url: '/pages/index/reserve/my-trip'
					// });
					uni.redirectTo({
						url:"/pages/user/my-order/orders"
					})
				}
			}
		}
	};
</script>